// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   NseerModuleTreeNode.java

package include;

import include.nseer_db.nseer_db;
import include.tree_index.Nseer;
import include.tree_index.businessComment;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import uk.ltd.getahead.dwr.WebContext;
import uk.ltd.getahead.dwr.WebContextFactory;

public class NseerModuleTreeNode
{

	WebContext ctx;
	HttpSession session;
	HttpServletRequest request;

	public NseerModuleTreeNode()
	{
		ctx = WebContextFactory.get();
		session = ctx.getSession();
		request = ctx.getHttpServletRequest();
	}

	public String Category(String categoryId, String tablename)
	{
		businessComment demo = new businessComment();
		demo.setPath(request);
		ServletContext context = session.getServletContext();
		String path = context.getRealPath("/");
		path = path.substring(0, path.length() - 1);
		int index = path.lastIndexOf("\\");
		path = path.substring(index + 1, path.length());
		Nseer n = new Nseer();
		nseer_db db = new nseer_db((String)session.getAttribute("unit_db_name"));
		nseer_db db1 = new nseer_db((String)session.getAttribute("unit_db_name"));
		String return_msg = "";
		String group_name = "erp";
		try
		{
			String sql = (new StringBuilder("select * from ")).append(tablename).append("_view where PARENT_CATEGORY_ID='").append(categoryId).append("' and human_ID='").append((String)session.getAttribute("human_IDD")).append("' and workflow_tag='0'").toString();
			for (ResultSet rs = db.executeQuery(sql); rs.next();)
				if (rs.getInt("DETAILS_TAG") == 1)
					return_msg = (new StringBuilder(String.valueOf(return_msg))).append("<div style=\"background: transparent url(/").append(path).append("/images/tree/l.gif) repeat-x 0 -15px;\"><a href=\"javascript:void(0)\" style=\"background-image:url(/").append(path).append("/images/tree/l.gif);width:100%;\" onMouseOver=\"window.status='powered by nseer erp'; return true\" onclick=\"toggleNode(this.parentNode,'").append(rs.getString("CATEGORY_ID")).append("','").append(tablename).append("'); return false;\"  onfocus=\"this.blur()\"><span style=\"padding:0px 0px 0px 3px\"><img src=\"/").append(path).append("/images/side.gif\" align=\"absmiddle\" style=\"border: 0;\" ></span><span style=\"padding:0px 0px 0px 8px\">").append(demo.getLang(group_name, rs.getString("file_name"))).append("</span></a></div>").toString();
				else
				if (!rs.getString("hreflink").equals(""))
					return_msg = (new StringBuilder(String.valueOf(return_msg))).append("<div style=\"background:#ffffff;width:100%\" class=\"hrefdiv\"><span style=\"padding:0px 0px 0px 3px\"><img src=\"/").append(path).append("/images/tree/2.gif\" align=\"absmiddle\" style=\"border: 0;\" ></span><span style=\"padding:0px 0px 0px 8px\"></span><A HREF=\"javascript:void(0);\" onmousedown=\"window.status='powered by nseer erp';this.href='javascript:void(0)';\" onmouseover=\"window.status='powered by nseer erp';this.href='javascript:void(0)'; return true\" onclick=\"changeColor(this,'/").append(path).append("/").append(rs.getString("file_path")).append(rs.getString("hreflink")).append("?readXml=n')\" onfocus=\"this.blur()\" >").append(demo.getLang(group_name, rs.getString("file_name"))).append("</A></div>").toString();
				else
					return_msg = (new StringBuilder(String.valueOf(return_msg))).append("<div style=\"background:#DDEAF6;width:100%\"><span style=\"padding:0px 0px 0px 3px\"><img src=\"/").append(path).append("/images/bean.JPG\" align=\"absmiddle\" style=\"border: 0;\" ></span><span style=\"padding:0px 0px 0px 8px\"></span>").append(demo.getLang(group_name, rs.getString("file_name"))).append("</div>").toString();

			db.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return return_msg;
	}
}
